USE [RedemptoristRetreat]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_VolunteerTaskXref_UserAccount]') AND parent_object_id = OBJECT_ID(N'[dbo].[VolunteerTaskXref]'))
ALTER TABLE [dbo].[VolunteerTaskXref] DROP CONSTRAINT [FK_VolunteerTaskXref_UserAccount]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_VolunteerTaskXref_VolunteerTask]') AND parent_object_id = OBJECT_ID(N'[dbo].[VolunteerTaskXref]'))
ALTER TABLE [dbo].[VolunteerTaskXref] DROP CONSTRAINT [FK_VolunteerTaskXref_VolunteerTask]
GO

USE [RedemptoristRetreat]
GO

/****** Object:  Table [dbo].[VolunteerTaskXref]    Script Date: 12/01/2013 14:30:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[VolunteerTaskXref]') AND type in (N'U'))
DROP TABLE [dbo].[VolunteerTaskXref]
GO

USE [RedemptoristRetreat]
GO

/****** Object:  Table [dbo].[VolunteerTaskXref]    Script Date: 12/01/2013 14:30:30 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[VolunteerTaskXref](
	[volunteerTaskId] [int] IDENTITY(1,1) NOT NULL,
	[userId] [int] NOT NULL,
	[taskId] [int] NOT NULL,
	[activeData] [tinyint] NULL,
	[modifiedBy] [varchar](25) NULL,
	[modifiedTimestamp] [datetime] NULL,
 CONSTRAINT [PK_VolunteerTaskXref] PRIMARY KEY CLUSTERED 
(
	[volunteerTaskId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[VolunteerTaskXref]  WITH NOCHECK ADD  CONSTRAINT [FK_VolunteerTaskXref_UserAccount] FOREIGN KEY([userId])
REFERENCES [dbo].[UserAccount] ([userId])
NOT FOR REPLICATION 
GO

ALTER TABLE [dbo].[VolunteerTaskXref] CHECK CONSTRAINT [FK_VolunteerTaskXref_UserAccount]
GO

ALTER TABLE [dbo].[VolunteerTaskXref]  WITH NOCHECK ADD  CONSTRAINT [FK_VolunteerTaskXref_VolunteerTask] FOREIGN KEY([taskId])
REFERENCES [dbo].[VolunteerTask] ([taskId])
NOT FOR REPLICATION 
GO

ALTER TABLE [dbo].[VolunteerTaskXref] CHECK CONSTRAINT [FK_VolunteerTaskXref_VolunteerTask]
GO

